﻿using System.Windows.Controls;
using Microsoft.VisualStudio.Text.Editor;

namespace Sentio.CodeReview.Editor
{
    public class CodeReviewControlMargin : Canvas, IWpfTextViewMargin
    {
        private bool _disposed = false;
        
        public CodeReviewControlMargin(IWpfTextViewHost wpfTextViewHost)
        {
            this.Children.Add(new CodeReviewControlBarUI(wpfTextViewHost));
        }

        public System.Windows.FrameworkElement VisualElement
        {
            get { 
                if(!_disposed)
                    return this;
                return null;
            }
        }

        public bool Enabled
        {
            get { 
                return !_disposed; 
            }
        }

        public ITextViewMargin GetTextViewMargin(string marginName)
        {
            return (marginName == CodeReviewControlBar.MarginName) ? (IWpfTextViewMargin)this : null;
        }

        public double MarginSize
        {
            get { return this.ActualHeight; }
        }

        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;
            }
        }
    }
}
